from rest_framework import serializers
from apps.UserControl.models import *


class UserSerializers(serializers.ModelSerializer):
    create_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)
    update_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)
    portrait = serializers.ImageField(required=False, read_only=True)
    # permission = serializers.SerializerMethodField()

    # def get_permission(self, obj):
    #     Permission = obj.user_permissions.all().order_by('id')
    #     return [{'id': item.id, 'name': item.name, 'code': item.codename, 'types': item.content_type_id} for item in Permission] if Permission else []

    class Meta:
        model = User
        fields = "__all__"
